<?php

class cntrlchart implements viewController {
	private $area;
	private $side;
	private $dependencies = array("JavaScript" => array("facebox.js", "creator.js", "printDialog.js", "chartloader.js", "chart.js"), "CSS" => array("facebox.css") );
	private $pageName = "PicBoard Communication Chart Viewer";

	public function __construct(user &$userObj){

		if( $userObj->getAccessLevel() == -1 ){
			// User is not logged in
			header("Location: home");
			exit;
		}
		
		parse_str( $_GET['act'] );
		
		$chartData = chart::getChart($userObj, $id);
		
		// Did we get the chart information successfully and is the user allowed to see it?
		if($chartData['status'] == "success"){			
			$this->dependencies['InlineJavaScript'][] = "var viewerOnly = true; var remoteChartData = " . json_encode($chartData['data']) . ";";
		} else {
			header("Location: error?e=166");
		}
		
		// Main area
		$this->area = new template("area.defaultGrid");
		
		// Side area.
		$this->side = new template("control.chartReadControls");	
	}
	
	public function getSide(){
		return $this->side;
	}
	
	public function getArea(){
		return $this->area;
	}
	
	public function getDependencies(){
		return $this->dependencies;
	}
	
	public function getPageName(){
		return $this->pageName;
	}

	public function getTools(){
		return "";
	}

}

?>